﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;

namespace ReutersForm
{
    public partial class Form1 : Form
    {
        private RegClass setIE = new RegClass();
        public Form1()
        {
            InitializeComponent();
            //ReadKey();
        }
        public void ReadKey()
        {
            //MessageBox.Show("Hello world!");
            string strPath = @"Software\Microsoft\Windows\CurrentVersion\Internet Settings";
            RegistryKey ieKey = Registry.CurrentUser.OpenSubKey(strPath, true);
            //ieKey.SetValue("AutoConfigURL", "www.123.com");
            object key = ieKey.GetValue("AutoConfigURL");
            //string key = ieKey.GetValue("PATH").ToString();
            MessageBox.Show(key.ToString());
            //MessageBox.Show(key);
        }
        public bool setAutoConfig(string strUrl)
        {
            return true;
        }
        private void HandlerCheckBoxXtraCheckedChanged(Object sender, System.EventArgs e)
        {
            if (checkBoxWeb.Enabled)
                checkBoxWeb.Enabled = false;
            else
                checkBoxWeb.Enabled = true;
            statuslabel.Text = "Select set Xtra option!";
        }
        private void HandlerCheckBoxWebCheckedChanged(Object sender, System.EventArgs e)
        {
            if (checkBoxXtra.Enabled)
                checkBoxXtra.Enabled = false;
            else checkBoxXtra.Enabled = true;
            statuslabel.Text = "Select set web option!";
        }
        private void HandlerButtonSetIEClicked(Object sender, System.EventArgs e)
        {
            if (checkBoxWeb.Enabled == true && checkBoxXtra.Enabled == true)
            {
                MessageBox.Show("Please select your option!");
                return;
            }
            if (checkBoxWeb.Enabled == true)
            {
                setIE.SetValue("AutoConfigURL", textBoxWeb.Text);
            //    MessageBox.Show("Done");
            }
            if (checkBoxXtra.Enabled == true)
            {
                setIE.SetValue("AutoConfigURL", textBoxXtra.Text);
            //    MessageBox.Show("Done");
            }
            statuslabel.Text = "Set the IE auto config successed!";
        }

        private void HandlerButtonReadKeyClicked(object sender, EventArgs e)
        {
            ReadKey();
        }
    }
}
